/***************************************************************************
 *  Filename: parrothandler.h
 *  Class: ParrotHandler
 *  
 *  Copyright 2012  Jacco van der Spek
 *  <jaccovdspek@gmail.com>
 *
 *  Copyright 2012  Mario Henrique Voorsluys
 *  <forcaeluz@gmail.com>
 *  
 ****************************************************************************/

/*
 *
 * This file is part of %ProjectName%.
 *
 *    %ProjectName% is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    %ProjectName% is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with %ProjectName%.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PARROTHANDLER_H
#define PARROTHANDLER_H

#include <QObject>
#include <communicationhandler.h>
#include "../../ArDroneController/uartmessages.h"

class ParrotHandler : public QObject {
    Q_OBJECT
public:
    ParrotHandler(QString port = "/dev/ttyUSB0", QObject *parent = 0);

public slots:
   void sendTakeOff();
   void sendLand();
   void sendReset();
   void sendEmergency();
   void sendGPSTarget(float lat, float lng, float altitude);
   void sendRelativeTarget(float x, float y, float z);

signals:
    void receivedVelocities(float vx, float vy, float vz);
    void receivedAngles(float roll, float pitch, float yaw);
    void receivedBattery(int perc);
    void receivedAltitude(int alt);

private slots:
    void readData();
private:
    void sendData(QByteArray data);
    CommunicationHandler communicator;
    QByteArray buffer;
    bool messageStarted;
};

#endif // PARROTHANDLER_H
